package course.d1229;

public class test {
    public static void main(String[] args) {
        Object obj = new Object();
        new Thread(){
            @Override
            public void run() {
                while (true){
                    synchronized (obj){
                        System.out.println("告知老板要的包子数量");
                        try {
                            obj.wait();
                            System.out.println("顾客吃包子");
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }

                }
            }
        }.start();

        new Thread(){
            @Override
            public void run() {
                while (true){
                        try {
                            Thread.sleep(3000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        synchronized (obj){
                            System.out.println("老板花3秒做包子");
                            obj.notify();

                        }
                }
            }
        }.start();
    }
}
